Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support conditional exports in js client #963

Conversation

perzeuss
Copy link
Contributor

@perzeuss perzeuss commented Aug 10, 2023

Description of changes

Currently not all bundlers will chose the correct CJS/ESM build when importing the js client because we don't define them using conditional-exports. This change adds the required configuration in the package.json to fix that.

  • Improvements & Bug fixes
    • support conditional exports in js client

Test plan

I have tested this manually. We have a Next.js setup which throws an error with v1.5.6, we make use of that to detect which build (cjs/esm) nextjs tries to load. In both cases we expect an error with the path from which nextjs loads the module.

Reproduce the issue

Failed to compile

./node_modules/chromadb/dist/main/embeddings/WebAIEmbeddingFunction.js:157:0
Module not found: Can't resolve '@visheratin/web-ai'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/chromadb/dist/main/index.js
./src/app/page.js

This error occurred during the build process and can only be dismissed by fixing the error.

Nextjs loads the cjs build from dist/main.

Confirm the change resolves the issue

Failed to compile

./node_modules/chromadb/dist/module/embeddings/WebAIEmbeddingFunction.js:131:0
Module not found: Can't resolve '@visheratin/web-ai'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/chromadb/dist/module/index.js
./src/app/page.js

This error occurred during the build process and can only be dismissed by fixing the error.

Nextjs now loads the esm build from dist/module

Documentation Changes

I added a reference to https://nodejs.org/api/packages.html#conditional-exports in the commit message

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readbility, Modularity, Intuitiveness)

Copy link
Contributor

@jeffchuber jeffchuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@jeffchuber jeffchuber merged commit f8186ff into chroma-core:main Aug 16, 2023
@mharis
Copy link

mharis commented Aug 22, 2023

Please release this version @jeffchuber

@jeffchuber
Copy link
Contributor

@mharis are you running into the nextjs issue as well?

i wanted to land and release this first - #956

@mharis
Copy link

mharis commented Aug 23, 2023

@jeffchuber

Yes, looking for nextjs compatibility. Very hack setup right now since break.

Hopefully the PRs merge and land in the npm package soon. :)

Thank you

@jeffchuber
Copy link
Contributor

@mharis ah sorry about this! I will finish testing #956 tonight and hopefully we can get that release out tonight or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants